package com.ygxsk.carhome.ui.complain;

import android.os.Bundle;
import android.text.TextUtils;
import android.view.View;

import androidx.annotation.NonNull;
import androidx.fragment.app.Fragment;
import androidx.recyclerview.widget.RecyclerView;

import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.serializer.SerializerFeature;
import com.blankj.utilcode.util.ActivityUtils;
import com.blankj.utilcode.util.LogUtils;
import com.blankj.utilcode.util.NetworkUtils;
import com.blankj.utilcode.util.StringUtils;
import com.blankj.utilcode.util.ToastUtils;
import com.chad.library.adapter.base.BaseQuickAdapter;
import com.chad.library.adapter.base.listener.OnItemChildClickListener;
import com.chad.library.adapter.base.listener.OnItemClickListener;
import com.scwang.smart.refresh.layout.SmartRefreshLayout;
import com.scwang.smart.refresh.layout.api.RefreshLayout;
import com.scwang.smart.refresh.layout.listener.OnRefreshLoadMoreListener;
import com.ygxsk.carhome.R;
import com.ygxsk.carhome.constant.ConstantApi;
import com.ygxsk.carhome.constant.ConstantSign;
import com.ygxsk.carhome.constant.ExtraKey;
import com.ygxsk.carhome.enumwrap.CallHistoryBusinessType;
import com.ygxsk.carhome.event.EventBusComplaintFeedBack;
import com.ygxsk.carhome.permission.PermissionSetting;
import com.ygxsk.carhome.response.ComplaintFeedBackBean;
import com.ygxsk.carhome.response.ComplaintFeedBackOutSide;
import com.ygxsk.carhome.retrofit.AddLogUpLoadInfo;
import com.ygxsk.carhome.retrofit.ApiException;
import com.ygxsk.carhome.retrofit.ApiRequestSubListener;
import com.ygxsk.carhome.retrofit.ApiService;
import com.ygxsk.carhome.retrofit.ErrorConsumer;
import com.ygxsk.carhome.retrofit.NetworkManager;
import com.ygxsk.carhome.retrofit.ResponseTransformer;
import com.ygxsk.carhome.ui.BaseImmersionFragment;
import com.ygxsk.carhome.ui.adapter.ComplainFeedBackListAdapter;
import com.ygxsk.carhome.utils.CommUtils;
import com.ygxsk.carhome.views.MyLinearLayoutManager;
import com.ygxsk.carhome.views.RecyclerViewAnimUtil;
import com.ygxsk.integrated.retrofit.Parameterkey;

import org.greenrobot.eventbus.EventBus;
import org.greenrobot.eventbus.Subscribe;
import org.greenrobot.eventbus.ThreadMode;

import java.util.ArrayList;
import java.util.HashMap;

import butterknife.BindView;
import io.reactivex.rxjava3.disposables.Disposable;
import io.reactivex.rxjava3.functions.Consumer;
import okhttp3.MediaType;
import okhttp3.RequestBody;

/**
 * A simple {@link Fragment} subclass.
 * Use the {@link ComplaintFeedBackOrHandlerFragment#newInstance} factory method to
 * create an instance of this fragment.
 * 投诉回访  的 【待处理】 和 【已处理】 的两个页面 通用的。
 */
public class ComplaintFeedBackOrHandlerFragment extends BaseImmersionFragment {

    @BindView(R.id.refreshlayoutincomplainfeedback)
    SmartRefreshLayout refreshLayoutInComplainFeedBack;

    @BindView(R.id.recyclerviewincomplainfeedback)
    RecyclerView recyclerViewInComplaInFeedBack;


//    private final String messageNull = "暂无数据~";

    /**
     * 携带顶部的类型的状态标识
     */
    private static final String ARG_STATUS = "status";

    /**
     * 携带顶部的类型的id信息
     */
    private static final String ARG_LABELID = "labelid";

    /**
     * 携带顶部的类型的名称信息
     */
    private static final String ARG_LABELNAME = "labelname";

    /**
     * 即将跳转到哪里
     */
    private static final String ARG_JUMPFROM = "jumpfrom";

    /**
     * 2019年10月26日傳入頁碼
     */
    //private int paginationPass = 1;

    /**
     * 默认是0 就是 全部的选项卡
     */
    private int arg_status = 0;

    /**
     * 2020年02月15日：最后一条工单的id信息，默认 第一页 不传递也行
     */
    //private String repairIdPass = "";

    /**
     * 接口加载更多的 上传最后一条投诉建议的id
     */
//    private String suggestionIdPass;

    //关于当Fragment可见的时候开始加载数据
//    protected boolean isVisible;

//    private boolean isViewPrepared;

    /**
     * 传递的状态
     */
    private String suggestionStatusPass;

    /**
     * 标志是从哪里过来的，那么将来详情就跳转到哪里
     */
    private int flag_jumpfrom_where;

    /**
     * 当前列表数据内容
     */
    private ArrayList<ComplaintFeedBackBean> mDataResources = new ArrayList<>();

    private ComplainFeedBackListAdapter complainFeedBackListAdapter;

    private int pagination_upLoad = Parameterkey.pageNum_default_first;


    public ComplaintFeedBackOrHandlerFragment() {
        // Required empty public constructor
    }

    /**
     * Use this factory method to create a new instance of
     * this fragment using the provided parameters.
     *
     * @return A new instance of fragment ComplainFeedBackFragment.
     */
    public static ComplaintFeedBackOrHandlerFragment newInstance(int arg_status, //
                                                                 String arg_labelid,//
                                                                 String arg_labelname,//
                                                                 int arg_jumpfrom) {//

        ComplaintFeedBackOrHandlerFragment fragment = new ComplaintFeedBackOrHandlerFragment();

        Bundle args = new Bundle();

        args.putInt(ARG_STATUS, arg_status);
        args.putString(ARG_LABELID, arg_labelid);
        args.putString(ARG_LABELNAME, arg_labelname);
        args.putInt(ARG_JUMPFROM, arg_jumpfrom);

        fragment.setArguments(args);

        return fragment;
    }

    /**
     * 该界面的权限弹窗
     */
    private PermissionSetting mSetting;

//    /**
//     * 该页面暂时因为token丢失造成需要添加他
//     */
//    private Session session;

    @Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);

        mFragmentInstance = this;
        mActivityInstance = this.getActivity();

        if (mDataResources == null) {
            mDataResources = new ArrayList<>();
        }

        mSetting = new PermissionSetting(this.getContext());

        //添加页面session
//        session = Session.get(this.getActivity());

        if (getArguments() != null) {

            //2020 这个值 也是从上个界面写死的，也是传递过来的值内容。
            arg_status = getArguments().getInt(ARG_STATUS);
            //mParam2 = getArguments().getString(ARG_PARAM2);

            flag_jumpfrom_where = getArguments().getInt(ARG_JUMPFROM);

            //如果是从【投诉处理】过来的
            if (flag_jumpfrom_where == ConstantApi.VALUE_JUMPFROM_HOMEMAINPAGE_COMPLAINTHANDLER_CLICK817) {

                //2021年10月21日14:09:35 振强给：[2，待处理；4，已处理/待回访；6已回访]
                if (arg_status == 0) {

                    LogUtils.d(ConstantSign.LOGCAT_NOMAL + "suggestionStatusPass=2");

                    suggestionStatusPass = "2";//未处理 传递1 或者传递2 都是待处理。
                } else if (arg_status == 1) {
                    suggestionStatusPass = "4";//已处理 传递4
                }

            } else if (flag_jumpfrom_where == ConstantApi.VALUE_JUMPFROM_HOMEMAINPAGE_COMPLAINTFEEDBACK_CLICK819) {

                if (arg_status == 0) {
                    suggestionStatusPass = "2";//未处理 传递1 或者传递2 都是待处理。
                } else if (arg_status == 1) {
                    LogUtils.d(ConstantSign.LOGCAT_NOMAL + "suggestionStatusPass=4");
                    suggestionStatusPass = "4";//已处理 传递4
                }

            } else {

                if (arg_status == 0) {
                    suggestionStatusPass = "2";//未处理 传递1 或者传递2 都是待处理。
                } else if (arg_status == 1) {
                    suggestionStatusPass = "4";//已处理 传递4
                }

            }

//            else if (flag_jumpfrom_where == ConstantApi.VALUE_JUMPFROM_HOMEMAINPAGE_COMPLAINTFEEDBACK_CLICK819) {
//
//                //如果是从【投诉回访】过来的
//                if (arg_status == 0) {
//                    suggestionStatusPass = "4";//待回访 传递4
//                } else if (arg_status == 1) {
//                    suggestionStatusPass = "6";//已回访 传递6
//                }
//
//            }

//            LogUtils.d("itchen---最终的-flag_jumpfrom_where==>" + flag_jumpfrom_where);
//            LogUtils.d("itchen---最终的-suggestionStatusPass==>" + suggestionStatusPass);

        }

        //列表之内需要向外部广播数据
        if (!EventBus.getDefault().isRegistered(this)) {
            EventBus.getDefault().register(this);
        }

    }

    @Override
    protected void gainDatas() {

        //2018/12/11 界面未完成又不是可见的那么直接返回
//        if (!isViewPrepared || !isVisible) {
//            LogUtils.d("itchen----->走到了不能展示逻辑");
//            return;
//        }

        //这个接口内就是刷新全部内容
//        suggestionIdPass = "";//重置

        pagination_upLoad = Parameterkey.pageNum_default_first;//重置

        if (mDataResources != null && !mDataResources.isEmpty()) {
            mDataResources.clear();
        }

        if (complainFeedBackListAdapter != null) {
            complainFeedBackListAdapter.notifyDataSetChanged();
        }

        if (NetworkUtils.isConnected()) {

            getServerDatas(suggestionStatusPass);

        } else {
            //是否有其他的执行逻辑？
            netWorkError();
            setEnableLoadmore(refreshLayoutInComplainFeedBack, true);
        }

    }

    private void getServerDatas(String _suggestionStatus) {

        HashMap<String, Object> hashMap = new HashMap<>();

//        hashMap.put(Parameterkey.suggestionId, _suggestionId);//最后一个工单的id信息:2023年8月15日14:24:21 不能按照这种分页方式

        hashMap.put(Parameterkey.shopInfoId, mSession.getShopInfoId());
        hashMap.put(Parameterkey.suggestionState, _suggestionStatus);
        hashMap.put(Parameterkey.pagination, pagination_upLoad);//该第几页
        hashMap.put(Parameterkey.pageSize, Parameterkey.pageSize_default);//一页多少条

        AddLogUpLoadInfo addLogUpLoadInfo = new AddLogUpLoadInfo();
        addLogUpLoadInfo.setActivity(mActivityInstance);
        addLogUpLoadInfo.setWhat(ConstantApi.WHAT_GETSUGGESTIONPAGEBYSOLVECUSTOMERID);
        addLogUpLoadInfo.setUrlPath(ApiService.staffGetCustomerSuggestionPage_url);
        addLogUpLoadInfo.setRequestMethod(ConstantSign.REQUEST_METHOD_POST);
        addLogUpLoadInfo.setToastToUser(true);//不需要展示给用户的,因为有上拉加载更多还是要提示下的
        addLogUpLoadInfo.setHashMapParameter(hashMap);

        //做界面展示给用户的
        NetworkManager.getInstance().initRetrofitRxJava()
                .create(ApiService.class)
                .staffGetCustomerSuggestionPage(RequestBody.create(JSON.toJSONString(hashMap,
                                SerializerFeature.PrettyFormat,
                                SerializerFeature.WriteMapNullValue),
                        MediaType.parse(ApiService.HEADER_JSON)))
//                .compose(ComplaintFeedBackOrHandlerFragment.this.bindUntilEvent(FragmentEvent.DESTROY))//
                .compose(new ResponseTransformer<>(addLogUpLoadInfo, //
                        new ApiRequestSubListener<ComplaintFeedBackOutSide>(ConstantApi.IS_FRAGMENT_ITSELF, ComplaintFeedBackOrHandlerFragment.this) {

                            @Override
                            public void handlerSomeThingNotSuccessDataForItSelf(int what_method, String serverCode, String serverMessage) {
                                super.handlerSomeThingNotSuccessDataForItSelf(what_method, serverCode, serverMessage);
                                methodNotSuccessData(what_method, serverCode, serverMessage);
                            }

                        }))
                .doOnSubscribe(new Consumer<Disposable>() {
                    @Override
                    public void accept(Disposable disposable) throws Exception {

                        LogUtils.d(ConstantSign.LOGCAT_NOMAL + "doOnSubscribe--doOnSubscribe--doOnSubscribe");

                        loadingGone();
                        setEnableLoadmore(refreshLayoutInComplainFeedBack, true);

                    }
                })
//                .subscribeOn(AndroidSchedulers.mainThread())//以上要执行主线程，因为界面处理要在主线程
                .subscribe(new Consumer<ComplaintFeedBackOutSide>() {//ArrayList<ComplaintFeedBackBean>

                    @Override
                    public void accept(ComplaintFeedBackOutSide complaintFeedBackOutSide) throws Exception {

                        if (complaintFeedBackOutSide != null) {

//                            {
//                                "code":"20000",
//                                    "data":{
//                                "dataCount":16,
//                                        "dataList":[],
//                                         "nextPagination":2,
//                                        "pagination":1,
//                                        "paginationCount":2
//                            },
//                                "message":"success"
//                            }

                            ArrayList<ComplaintFeedBackBean> complaintFeedBackBeans = complaintFeedBackOutSide.getDataList();

                            if (complaintFeedBackBeans != null && !complaintFeedBackBeans.isEmpty()) {

                                //String dataJsonString = JSON.toJSONString(datas);
                                //区分 是 工单回访 还是 我的工单列表 :工单回访也是这个列表
                                // methodHandlerLocalData(dataJsonString); 做离线缓存的数据内容。
//                                methodLoadPage(complaintFeedBackBeans);

                                if (mDataResources != null) {
                                    mDataResources.addAll(complaintFeedBackBeans);
                                }

                                //做空数据处理
                                if (complainFeedBackListAdapter != null) {
                                    complainFeedBackListAdapter.notifyDataSetChanged();
                                }


                                pagination_upLoad = complaintFeedBackOutSide.getNextPagination();

                                //对列表改造：
                                if (pagination_upLoad == Parameterkey.GET_NEXT_PAGINATION) {
                                    setFinishLoadMoreWithNoMoreData(refreshLayoutInComplainFeedBack, true);
                                } else {
                                    setEnableLoadmore(refreshLayoutInComplainFeedBack, true);
                                }

                            } else {

                                //页面遮挡
                                setEnableLoadmore(refreshLayoutInComplainFeedBack, false);
//                    LogUtils.d(ConstantSign.LOGCAT_NOMAL + "mDataResources.isEmpty--mDataResources.isEmpty--mDataResources.isEmpty");
                                //页面的遮盖:
                                fillNullDataView(StringUtils.getString(R.string.nulldatanow), R.drawable.errorsear);

                                if (complainFeedBackListAdapter != null) {
                                    complainFeedBackListAdapter.notifyDataSetChanged();
                                }

                            }

                        }
                    }

                }, new ErrorConsumer() {
                    @Override
                    protected void error(ApiException e) {

                        function_apiException(e);

                    }
                });
    }

    @Override
    public void methodNotSuccessData(int what_method, String _statusCode, String _message) {
        super.methodNotSuccessData(what_method, _statusCode, _message);

        switch (what_method) {

            case ConstantApi.WHAT_GETSUGGESTIONPAGEBYSOLVECUSTOMERID: {

//                LogUtils.d(ConstantSign.LOGCAT_NOMAL + "methodNotSuccessData--methodNotSuccessData--methodNotSuccessData");

                if (mDataResources != null && mDataResources.isEmpty()) {
//                    //上拉加载更多也不可用
                    setEnableLoadmore(refreshLayoutInComplainFeedBack, false);

//                    LogUtils.d(ConstantSign.LOGCAT_NOMAL + "mDataResources.isEmpty--mDataResources.isEmpty--mDataResources.isEmpty");

                    //页面的遮盖:
                    CommUtils.checkCurrently(mFragmentInstance,//
                            _statusCode,//
                            R.drawable.errorsear,//
                            _message,//
                            getString(R.string.nulldatanow));
                } else {
                    LogUtils.d(ConstantSign.LOGCAT_NOMAL + "mDataResources是空的");
                }

                break;
            }

            default:
                break;
        }

// : 2023-08-11 15:04 代码勿删

//        CommTools.errorTokenOrEqument(mActivityInstance, _statusCode, _message, session, new SequenceListener() {
//
//            @Override
//            public void doSomeThing() {
//
//                //{"data":"","message":"无数据","code":"20002"}
//
//                LogUtils.d(ConstantSign.LOGCAT_NOMAL+"methodNotSuccessData");
//
//                //有可能一进来界面 就是无数据的内容
//                if (mDataResources != null && mDataResources.isEmpty()) {
//                    //上拉加载更多也不可用
//                    setEnableLoadmore(refreshLayoutInComplainFeedBack, false);
//
//                    //页面的遮盖:
//                    CommUtils.checkCurrently((ErrorActivity) mActivityInstance,//
//                            _statusCode,//
//                            R.drawable.errorsear,//
//                            _message,//
//                            getString(R.string.nulldatanow));
//                }
//            }
//        });

    }

    /**
     * 加载该页面的数据内容
     */
//    private void methodLoadPage(List<ComplaintFeedBackBean> _datas) {
//
//        if (mDataResources != null) {
//
//            mDataResources.addAll(_datas);
////            suggestionIdPass = mDataResources.get(mDataResources.size() - 1).getSuggestionId();
//
//        }
//
//        //做空数据处理
//        if (complainFeedBackListAdapter != null) {
//            complainFeedBackListAdapter.notifyDataSetChanged();
//        }
//
//    }


//    @Override
//    public void setUserVisibleHint(boolean isVisibleToUser) {
//        super.setUserVisibleHint(isVisibleToUser);
//
//        //LogUtils.d("itchen--setUserVisibleHint="+getUserVisibleHint());
//
//        if (getUserVisibleHint()) {//可见的
//
//            isVisible = true;
//
//            gainDatas();
//
//        } else {
//
//            isVisible = false;
//            //onInvisible();--不执行任何操作
//        }
//
//    }
    @Override
    protected void initView() {
        super.initView();

        initViews();

//        isViewPrepared = true;

    }

    @Override
    protected void initData() {
        super.initData();

        gainDatas();

    }

    private void initViews() {

//        refreshLayoutInComplainFeedBack = (SmartRefreshLayout) mRootView.findViewById(R.id.refreshlayoutincomplainfeedback);
//        recyclerViewInComplaInFeedBack = (RecyclerView) mRootView.findViewById(R.id.recyclerviewincomplainfeedback);
//        recyclerViewInComplaInFeedBack.clearAnimation();

        if (ActivityUtils.isActivityAlive(mActivityInstance)) {
            recyclerViewInComplaInFeedBack.setLayoutManager(new MyLinearLayoutManager(mActivityInstance));
        } else {
            recyclerViewInComplaInFeedBack.setLayoutManager(new MyLinearLayoutManager(mActivityInstance));
        }

        //去掉局部刷新的动画
        RecyclerViewAnimUtil.getInstance().closeDefaultAnimator(recyclerViewInComplaInFeedBack);

        //该界面的适配器内容
        complainFeedBackListAdapter = new ComplainFeedBackListAdapter(R.layout.complaintfeedbacklistadapter, mDataResources);
        recyclerViewInComplaInFeedBack.setAdapter(complainFeedBackListAdapter);
        complainFeedBackListAdapter.notifyDataSetChanged();

        //--------------------------------------------------------------------------------------------------------------------------
        //设置子类的点击事件

        complainFeedBackListAdapter.setOnItemChildClickListener(new OnItemChildClickListener() {
            @Override
            public void onItemChildClick(@NonNull BaseQuickAdapter<?, ?> adapter, @NonNull View view, int position) {

                //获取单个条目的内容
                ComplaintFeedBackBean complainFeedBackBeanItem = (ComplaintFeedBackBean) adapter.getItem(position);

                switch (view.getId()) {

                    case R.id.textviewphonenumberincomplain: {//拨打电话的二次弹窗确认

                        if (complainFeedBackBeanItem != null) {
                            //CommTools.methodPhone(mActivityInstance, complainFeedBackBeanItem.getPhone(), mAlertView, mSetting);
                            clickButton_toCallPhone(mActivityInstance, complainFeedBackBeanItem.getPhone(), CallHistoryBusinessType.BUSINESSTYPE_2.getIndex());
                        } else {
                            ToastUtils.showShort(getString(R.string.getphoneinfofail));
                        }

                        break;
                    }

                    case R.id.imageviewphoneinfeedbacklist: {//拨打电话的二次弹窗确认

                        if (complainFeedBackBeanItem != null) {
                            //CommTools.methodPhone(mActivityInstance, complainFeedBackBeanItem.getPhone(), mAlertView, mSetting);
                            clickButton_toCallPhone(mActivityInstance, complainFeedBackBeanItem.getPhone(), CallHistoryBusinessType.BUSINESSTYPE_2.getIndex());
                        } else {
                            ToastUtils.showShort(getString(R.string.getphoneinfofail));
                        }

                        break;
                    }


                    default:
                        break;
                }

            }
        });

        //--------------------------------------------------------------------------------------------------------------------------
        //条目的点击事件内容
        complainFeedBackListAdapter.setOnItemClickListener(new OnItemClickListener() {
            @Override
            public void onItemClick(@NonNull BaseQuickAdapter<?, ?> adapter, @NonNull View view, int position) {

                //获取单个条目的内容
                ComplaintFeedBackBean complainFeedBackBeanItem = (ComplaintFeedBackBean) adapter.getItem(position);

                if (complainFeedBackBeanItem != null) {

                    //弄一个string串的内容 做下边逻辑的比对。
                    String suggestionStateInItemTopTemp = String.valueOf(complainFeedBackBeanItem.getSuggestionState());
                    Bundle extras_handler_feedback = new Bundle();

                    //携带这条数据的id
                    extras_handler_feedback.putString(ExtraKey.EXTRA_COMPLAINTFEEDBACK_SUGGESTIONID, complainFeedBackBeanItem.getSuggestionId());
//                    //只是携带一个 【待回访】或者【已处理】的状态就可以。
                    extras_handler_feedback.putInt(ExtraKey.EXTRA_COMPLAINTFEEDBACK_SUGGESTION_STATE, complainFeedBackBeanItem.getSuggestionState());

                    //------------------------以上是通用的代码----------------------------------------------------------------------------------------------------
                    if (flag_jumpfrom_where == ConstantApi.VALUE_JUMPFROM_HOMEMAINPAGE_COMPLAINTFEEDBACK_CLICK819) {
                        //已处理 过来的

                        //如果大前提 是从【投诉回访】过来的。
//                        if (TextUtils.equals(suggestionStateInItemTopTemp, ConstantApi.VALUE_COMPLAINT_SUGGESTIONS_NO_FEEDBACK_STATE_4)) {//待回访 未回访的
//
//                            //振强：【2，待处理；4，已处理/待回访；6已回访】
//                            extras_handler_feedback.putInt(ConstantApi.EXTRA_COMPLAINT_FEEDBACK_OR_HANDLER_TYPE, ConstantApi.VALE_COMPLAINT_TYPE_FEEDBACK_CLICK819);
//                            //2021年10月21日15:23:54 新增 是从【工单池--工单回访--待回访】跳转到  回访界面的
//                            //extras_handler_feedback.putInt(ConstantApi.EXTRA_JUMPFROM_WHERE, ConstantApi.VALUE_JUMPFROM_COMPLAINT_SUGGESTIONS_NO_FEEDBACK_STATE_4);
//                            extras_handler_feedback.putInt(ConstantApi.EXTRA_JUMPFROM_WHERE, ConstantApi.VALUE_JUMPFROM_COMPLAINT_FEEDBACK_NO_FEEDBACK);
//
//                            //携带投诉回访 的未回访的内容id.
//                            extras_handler_feedback.putString(ConstantApi.EXTRA_COMPLAINT_FEEDBACK_SUGGESTIONID, complainFeedBackBeanItem.getSuggestionId());
//
//                            ActivityUtils.startActivity(extras_handler_feedback, WorkPoolFeedBackAddSubmitActivity.class);
//
//                        }

                        extras_handler_feedback.putInt(ConstantSign.EXTRA_COMPLAINT_FEEDBACK_OR_HANDLER_TYPE, ConstantApi.VALE_COMPLAINT_TYPE_FEEDBACK_CLICK819);
                        ActivityUtils.startActivity(extras_handler_feedback, ComplainFeedBackOrHandlerDetailActivity.class);


                    } else if (flag_jumpfrom_where == ConstantApi.VALUE_JUMPFROM_HOMEMAINPAGE_COMPLAINTHANDLER_CLICK817) {

                        //未处理 过来的

//                        //如果大 的前提 是从【投诉处理】过来的。
                        if (TextUtils.equals(suggestionStateInItemTopTemp, ConstantApi.VALUE_COMPLAINT_SUGGESTIONS_NO_ALLOCATE_STATE_1)
                                || TextUtils.equals(suggestionStateInItemTopTemp, ConstantApi.VALUE_COMPLAINT_SUGGESTIONS_NO_HANDLER_STATE_2)) {//待处理

//                            extras_handler_feedback.putInt(ExtraKey.EXTRA_JUMPFROM_WHERE, .VALUE_JUMPFROM_COMPLAINT_FEEDBACK_NO_FEEDBACK);
                            //王振强：【2，待处理；4，已处理/待回访；6已回访】
                            extras_handler_feedback.putInt(ConstantSign.EXTRA_COMPLAINT_FEEDBACK_OR_HANDLER_TYPE, ConstantApi.VALE_COMPLAINT_TYPE_HANDLER_CLICK817);
                            //只有这种情况才有的  去提交处理内容。 携带这个标识过去的 是要刷新列表的。
                            extras_handler_feedback.putInt(ConstantSign.EXTRA_COMPLAINTFEEDBACK_SUGGESTION_STATUS_INLIST, ConstantApi.VALUE_COMPLAINTFEEDBACK_SUGGESTION_STATUS_NO_HANDLER);

                            ActivityUtils.startActivity(extras_handler_feedback, ComplainFeedBackOrHandlerDetailActivity.class);

                        }

//                        else if (TextUtils.equals(suggestionStateInItemTopTemp, ConstantApi.VALUE_COMPLAINT_SUGGESTIONS_HAVED_HANDLER_STATE_4)) {//已处理 6
//                            extras_handler_feedback.putInt(ConstantApi.EXTRA_COMPLAINT_FEEDBACK_OR_HANDLER_TYPE, ConstantApi.VALE_COMPLAINT_TYPE_HANDLER_CLICK817);
//                            ActivityUtils.startActivity(extras_handler_feedback, ComplainFeedBackOrHandlerDetailActivity.class);
//                        }

                    }

                } else {
                    //是空的实体内容，那末，就不要跳转。
                }


            }
        });

        refreshLayoutInComplainFeedBack.setOnRefreshLoadMoreListener(new OnRefreshLoadMoreListener() {

            @Override
            public void onRefresh(@NonNull RefreshLayout refreshLayout) {

                refreshLayout.getLayout().post(new Runnable() {
                    @Override
                    public void run() {

                        if (NetworkUtils.isConnected()) {

                            pagination_upLoad = Parameterkey.pageNum_default_first;

                            if (mDataResources != null && !mDataResources.isEmpty()) {
                                mDataResources.clear();
                            }

                            //重置，这里就置为空。
//                            suggestionIdPass = "";

                            getServerDatas(suggestionStatusPass);

                        } else {
                            netWorkError();
                        }

                        refreshLayout.finishRefresh();

                    }
                });

            }

            @Override
            public void onLoadMore(@NonNull RefreshLayout refreshLayout) {

                refreshLayout.getLayout().post(new Runnable() {
                    @Override
                    public void run() {

                        if (NetworkUtils.isConnected()) {

                            getServerDatas(suggestionStatusPass);

                        } else {
                            netWorkError();
                        }

                        refreshLayout.finishLoadMore();

                    }
                });
            }
        });


    }

    @Subscribe(threadMode = ThreadMode.MAIN)
    public void onEventMainThreadInComplaintFeedBack(EventBusComplaintFeedBack eventBusComplaintFeedBack) {

        if (eventBusComplaintFeedBack != null) {

            if (eventBusComplaintFeedBack.getMessage() == ConstantApi.EVENTBUS_COMPLAINTFEEDBACK_SUBMIT_SUCCESS) {

                LogUtils.d("itchen----提交回访完毕，收到了--EVENTBUS_COMPLAINTFEEDBACK_SUBMIT_SUCCESS 消息-");

                //提交 回访完毕 那么就直接刷新列表
                gainDatas();

            }

        }
    }

    @Override
    public void onDestroy() {
        super.onDestroy();

        //列表的id释放
//        suggestionIdPass = "";

        //其他释放
        suggestionStatusPass = "";

        if (mDataResources != null && (!mDataResources.isEmpty())) {

            mDataResources.clear();

            //一起刷新数据
            if (complainFeedBackListAdapter != null) {
                complainFeedBackListAdapter.notifyDataSetChanged();
                //释放一块做了
                complainFeedBackListAdapter = null;
            }
        }

        if (mSetting != null) {
            mSetting = null;
        }

        if (mDataResources != null && !mDataResources.isEmpty()) {
            mDataResources.clear();
        }

        if (complainFeedBackListAdapter != null) {
            complainFeedBackListAdapter.notifyDataSetChanged();
            complainFeedBackListAdapter = null;
        }

        CommUtils.checkDialog(mAlertView);

        if (isAdded()) {//这个在onStop内解绑的话会导致在详情内取消订单，导致无法刷新主界面。
            //LogUtils.d("itchen--解绑--" + this.toString());
            EventBus.getDefault().unregister(this);
        }

    }

    @Override
    protected int getLayoutId() {
        return R.layout.fragment_complain_feed_back;
    }

    @Override
    public void onClickNodata(View view) {

        //页面内容。
        gainDatas();

    }
}